<?php
if (!defined('TOBBIVM')) header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Erste Zeile: Kurzbeschreibung für �bersichten.
 *
 * Mehrzeiliger, optionaler Dokumentationsblock.
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */

function leftmenu($selectedPage, $selectetSubPage, $refPage )
{
	$info = array('info',
				_('Info'),
				  'info',
				_('Info') );

	$page = array('page',
				_('Pages'),
				  'startpage',
				_('Startpage'),
				  'imprint',
				_('Imprint'),
				  'terms',
				_('Terms and conditions'),
				  'revocation',
				_('Revocation Instruction'),
				  'about',
				_('About us'),
				'hr',
				'line',
					'new_registration',
				_('New Registration') );

	$mail = array('mail',
				_('Mail'),
				  'contact',
				_('Contact'),
				  'confirm',
				_('Confirmation'),
				  'sent',
				_('Sent') );

	$article = array('article',
				   _('Article'),
				     'category',
				   _('Category'),
				     'article',
				   _('Article'),
				     'calculator',
				   _('Calculator') );

	$user = array('user',
				_('User'),
				  'admin',
				_('Admins'),
				  'customers',
				_('Customers') );

	$config = array('config',
				  _('Configuration'),
				    'server',
				  _('Server'),
				    'tax',
				  _('Tax'),
					 'measure',
				  _('Measure table'),
				    'pricelist',
				  _('Price lists'),
				    'backup',
				  _('DB-Backup'),
				    'restore',
				  _('DB-Restore') );

	$file = array('file',
				_('Filesystem'),
				  'global',
				_('Global'),
				  'images',
				_('Images') );


	if (!in_array($selectetSubPage, $$selectedPage, TRUE) and $selectetSubPage <> '-')
	{
		header('location:/admin/index2.php?page=info&sub=info');
		exit;
	}

	$pageBuffer = '';
	$subMenu = $$selectedPage;

	// Create Leftmenu
	if ($selectetSubPage === '-')
	{
		$_GET['sub'] = $subMenu[2];
		$selectetSubPage = $subMenu[2];
	}

	for( $i=2; $i <= (count( $subMenu ) -1); $i += 2 )
	{
		// Setting class for aktive Menueitem
		if ($selectetSubPage === $subMenu[$i])
		{
			$class = 'menuitem_green';
		} else {
			$class = 'menuitem';
		}

		if ($subMenu[$i] === 'hr')
		{
			$pageBuffer .= '<hr>';
		}
		else
		{
			$pageBuffer .= '<a class="' . $class . '" href="index2.php?page=' . $selectedPage .
				'&sub=' . $subMenu[$i] . '">' . $subMenu[$i+1] . '</a>';
		}
	}
	$refPage->assign('leftmenu', $pageBuffer);
}
?>